var app = angular.module('myApp',[]);
app.controller('login',['$scope','$http',function($scope,$http){
    //登录
    $scope.login = function(){
        $http({
            method:'get',
            url:'data/user.json'
        }).then(function(res){
            var userName = $scope.userName;
            var userPwd = $scope.userPwd;
            for(var i=0;i<res.data.length;i++){
                if(userName == res.data[i].name){
                    if(userPwd == res.data[i].password){
                        window.location.href = 'index.html#!/list:1';
                    }else{
                        layer.msg('用户名或密码不正确',{time:1000});
                    }
                }else{
                    layer.msg('用户名或密码不正确',{time:1000});
                }
            }
        });
    };

    //重置
    $scope.reset = function(){
        $scope.userName = '';
        $scope.userPwd = '';
    };
}]);